<?php
	if(isset($_POST['adata']))
{
	require("includes/basic.php");
	$d=$_POST['adata'];
	$id= split(',',$d);
	foreach($id as $a => $b)
	{
		$activatep=mysql_query("update vendor_master set record_status='Y' where vendor_id=$b");
	}
	
}
if(isset($_POST['data']))
{
	require("includes/basic.php");
	$d=$_POST['data'];
	$id= split(',',$d);
	foreach($id as $a => $b)
	{
		$deactivatep=mysql_query("update vendor_master set record_status='N' where vendor_id=$b");	
	}
	
}
if(isset($_POST['s']))
{
	require("includes/basic.php");
	$s=$_POST['s'];
	$sql="select * from vendor_master where LOWER(vendor) like LOWER('%$s%') or LOWER(vendor_desc) like LOWER('%$s%')";
}
else
{


$sql="select * from vendor_master";

}
include('ps_pagination.php'); 
$pager = new PS_Pagination($conn, $sql, 8, 5, "param1=valu1&param2=value2");
	
	/*
	 * Enable debugging if you want o view query errors
	*/
	$pager->setDebug(true);
	
	/*
	 * The paginate() function returns a mysql result set
	 * or false if no rows are returned by the query
	*/
	$rs = $pager->paginate();
	if(!$rs) die(mysql_error());


	$sr=1;
$class="evenrowbg";	

?>
<form id='viewvendors'> 

	<table width='100%' cellpadding='1' cellspacing='0' class='list'>
	<tr>
		<!-- <th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Sr no.</span>
			</div>
		</th> -->
		<th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Open</span>
			</div>
		</th>
        <th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Edit</span>
			</div>
		</th>
		<th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Contact</span>
			</div>
		</th>
		<th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Vendor</span>
			</div>
		</th>
		<th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Vendor Description</span>
			</div>
		</th>
		<!-- <th style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">Mobile</span>
		</th>
		<th style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">Address</span>
		</th> -->
		<th style='white-space: nowrap;'>
			<div style='display:block; '>
				<span class="link linkdisabled">Vendor Username</span>
			</div>
		</th>
		<!--<th style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">Vendor Password</span>
		</th>-->
		
		<th style='white-space: nowrap;'>
			<span class="link linkdisabled">Record Status</span>
		</th>
		<!--<th width='10%' style='white-space: nowrap;'>
			<span class="link">Status</span>
		</th>-->
		<th class='select'>
			
<input type='checkbox' class='checkbox' name='allCheck' id='listSelectAll'>
		</th>
	</tr>
	<?php while($vendortr = mysql_fetch_array($rs)) {
		$vendorid=$vendortr['vendor_id'];
		$vendorname=$vendortr['vendor'];
		$vendorDesc=$vendortr['vendor_desc'];
		$vendorUname=$vendortr['user_name'];
		$vendorpass=base64_decode($vendortr['password']);
		$vendorstatus=$vendortr['record_status'];
			
		if($class=="evenrowbg")
		{
			$class="oddrowbg";
		}
		else
		{
			$class="evenrowbg";
		}
		echo "<tr class='$class' >";
		//echo "<td style='text-align:center;'>$sr</td>";
		echo "<td style='text-align:center;'><a href='open_vendors.php?open=$vendorid'><img src='images/open.png'/></a></td>";
		echo "<td style='text-align:center;'><a href='edit-vendors.php?vendorid=$vendorid'><img src='images/edit.png'/></a></td>";
		echo "<td style='text-align:center;'><a href='viewvendor-contact.php?vendorCid=$vendorid'><img src='images/user.png'/></a></td>";
		echo "<td>".$vendorname."</td><td>".$vendorDesc."</td>";
		
		/* $qa=mysql_query("select * from vendor_contact where customer_id=".$custid);
		$row=mysql_fetch_array($qa);
		//extract($row);
		$mobile=$row['mobile'];
		$address=$row['address']; */

		//echo "<td>...</td><td>...</td>";
		echo "<td>".$vendorUname."</td>";
		/*$pdoc=mysql_query("select * from project_doc where project_id=".$projectid);
		$noOfdocs=mysql_num_rows($pdoc);*/
		//echo "<td>$noOfdocs</td><td>";
		//$client=mysql_query("select c.* from client_master c, client_project cp where c.client_id=cp.client_id and cp.project_id=$projectid");
		/*if(mysql_num_rows($client)>0)
		{
			while($clientr=mysql_fetch_array($client))
			{
			extract($clientr);
			$clientname=$clientr['client_name'];
			echo $clientname."<br/>";
			}
		}
		echo "</td><td style='text-align:center;'>";*/		
		echo "<td style='text-align:center'>";
		if($vendorstatus=='Y')
		{
			echo "<img src='images/multi_activate.png' alt='Active' title='Active'>";
		}
		else
		{
			echo "<img src='images/multi_deactivate.png' alt='Disabled' title='Disabled'>";
		}
		echo "</td>";
		echo "<td style='text-align:center;'><input type='checkbox' value='$vendorid' id='chkName' name='chkName'></td>";
		$sr++;
	}
	//echo Pages("tutorials",$perpage,"view-customers.php?");	

	?>
</form>

</table>

<?php

	//Display the full navigation in one go
	 echo "<br />\n";?>
	<span style="text-align:justify; margin-left:320px;"><?php  echo $pager->renderFullNav(); ?> </span>

